using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LevelData;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace GGJ11
{
    //draw money
    class RenderingGameObject : RenderingEnemies
    {

        Level level;

        public RenderingGameObject() { }
        public RenderingGameObject(ContentManager Content)
            : base(Content)
        {
            level = Content.ServiceProvider.GetService(typeof(Level)) as Level;
            
        }

        //draw money
        public void Draw(GameTime gameTime, SpriteBatch sp, Vector2 visibleHArea, Vector2 visibleVArea)
        {

            for (int i = 0; i < level.ObjectList.Count; i++)
            {
                if (level.ObjectList[i].posX >= visibleHArea.X && level.ObjectList[i].posX <= visibleHArea.Y)
                {
                    if (level.ObjectList[i].posY >= visibleVArea.X && level.ObjectList[i].posY <= visibleVArea.Y)
                    {
                        if(level.ObjectList[i].type != ObjectType.openExit)
                            level.ObjectList[i].sprite.Draw(gameTime, sp, level.ObjectList[i].position, SpriteEffects.None);
                        else if(!level.ObjectList[i].open)
                            level.ObjectList[i].sprite.Draw(gameTime, sp, level.ObjectList[i].position, SpriteEffects.None);
                    }
                }
            }
            base.Draw(gameTime, sp, visibleHArea, visibleVArea);
        }

        //update service when load a next level
        public void UpdateLevelService(ContentManager content)
        {
            level = content.ServiceProvider.GetService(typeof(Level)) as Level;
            base.UpdateLevelService(content);

        }
    }
}
